package com.badibadi.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.util.LangUtils;

import com.badibadi.fragment.RecordFragment1;
import com.badibadi.fragment.RecordFragment2;
import com.badibadi.infos.RecordModel;
import com.badibadi.infos.Results;
import com.badibadi.infos.UserInfoModel;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.JSONUtils;
import com.badibadi.mytools.MyThreadTool;
import com.badibadi.mytools.Utils;
import com.badibadi.uniclubber.R;
import com.badibadi.uniclubber.R.id;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

/**
 * 查看别人的记录
 * 
 * @author Administrator
 * 
 */
public class RecordListFriendsActivity extends RecordMyRecordListActivity {

	UserInfoModel userInfoModel = null;// uid

	TextView tv;
	private Handler mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				Utils.ExitPrgress(RecordListFriendsActivity.this);
				// try {
				// // Utils.showMessage(RecordListFriendsActivity.this,
				// "网络连接出错");
				// } catch (Exception e) {
				// // TODO: handle exception
				// }
				break;
			case 2:
				try {
					if (tv != null)
						tv.setText("" + userInfoModel.getNickName() + getResources().getString(R.string.l_xb136));
					// list
					// if(isShangla==true)
					// {
					// xListView1.requestLayout();
					// // x1Adapter.setmList(mList);
					// mList.addAll(list);
					// x1Adapter.notifyDataSetChanged();
					// onLoad();
					// isShangla=false;
					// }

				} catch (Exception e) {
					// TODO: handle exception
				}

				break;
			case 3:
				// Utils.ExitPrgress(RecordListFriendsActivity.this);
				//
				// try {
				// Utils.showMessage(RecordListFriendsActivity.this, "已经没有更多咯");
				// } catch (Exception e) {
				// // TODO: handle exception
				// }
				break;
			case 4:
				// Utils.ExitPrgress(RecordListFriendsActivity.this);
				// // try {
				// //// Utils.showMessage(getActivity(), results2.getRetmsg());
				// // } catch (Exception e) {
				// // // TODO: handle exception
				// // }
			default:
				break;
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.findViewById(R.id.my_record_list_bottom_button).setVisibility(
				View.GONE);
		
	
		
		init();

//		initInterNet0();
	}
	@Override
	protected void initFragment() {
		// TODO Auto-generated method stub
		uid=getIntent().getStringExtra("uid");
		fid=Utils.getUid(RecordListFriendsActivity.this);
		if (uid == null) {
			uid = "1";
		}
		if (fid == null) {
			fid = "-1";
		}
		super.initFragment();
	}
	
	

	private void initInterNet0() {
		// TODO Auto-generated method stub
		MyThreadTool.fixedThreadPool.execute(new Runnable() {
			@Override
			public void run() {

				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", uid);
//				   
                
				map.put("languageType", com.badibadi.mytools.Dialog
						.getSystemLanguageType(RecordListFriendsActivity.this));
				String invite_content = Utils.sendRequest(map,
						Constants.BadiUrl + "userDataShow");
				//    
				if (invite_content != null) {
					Results results = Utils.checkResult_NNN(
							RecordListFriendsActivity.this, invite_content);
					if (results != null && !results.getRetmsg().equals("null")) {
						//    
						try {
							userInfoModel = JSONUtils.getEntityByJsonString(
									results.getRetmsg(), UserInfoModel.class);
							// mList.addAll(list);
							mHandler.sendEmptyMessage(2);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							   
						}
					} else {

						mHandler.sendEmptyMessage(3);
					}
				} else {

					mHandler.sendEmptyMessage(1);
				}

			}
		});
	}

	private void init() {
		tv = ((TextView) (this.findViewById(R.id.my_record_tiltle)));
		tv.setText(getResources().getString(R.string.record));
		this.findViewById(R.id.my_record_record).setVisibility(View.GONE);
	}

	@Override
	protected void LoadingFragment(int num, String uid, String fid) {
		// TODO Auto-generated method stub
		super.LoadingFragment(num, this.uid, this.fid);

	}
}
